﻿@using DragonSolution.Web.Common.Common;
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>发布新闻</title>
    <link rel="stylesheet" href="~/Areas/AdminMrg/kindeditor-4.1.10/themes/default/default.css" />
    <link rel="stylesheet" href="~/Areas/AdminMrg/kindeditor-4.1.10/plugins/code/prettify.css" />
    <script charset="utf-8" src="~/Areas/AdminMrg/kindeditor-4.1.10/kindeditor.js"></script>
    <script charset="utf-8" src="~/Areas/AdminMrg/kindeditor-4.1.10/lang/zh_CN.js"></script>
    <script charset="utf-8" src="~/Areas/AdminMrg/kindeditor-4.1.10/plugins/code/prettify.js"></script>
    <script>
	    KindEditor.ready(function (K) {
	        var editor1 = K.create('#NewsContent', {
	            cssPath: '/Areas/AdminMrg/kindeditor-4.1.10/plugins/code/prettify.css',
	            uploadJson: '/Areas/AdminMrg/kindeditor-4.1.10/asp.net/upload_json.ashx',
	            fileManagerJson: '/Areas/AdminMrg/kindeditor-4.1.10/asp.net/file_manager_json.ashx',
	            allowFileManager: true,
	            afterBlur: function () { this.sync(); },
	            afterCreate: function () {
	                var self = this;
	                K.ctrl(document, 13, function () {
	                    self.sync();
	                    K('form[name=example]')[0].submit();
	                });
	                K.ctrl(self.edit.doc, 13, function () {
	                    self.sync();
	                    K('form[name=example]')[0].submit();
	                });
	            }
	        });
	        prettyPrint();
	    });
    </script>
    <style type="text/css">
        #comInfo { width: 1000px; float: left; margin-left: 8px; display: inline; }
            #comInfo ul li { height: 26px; line-height: 26px; float: left; margin-top: 5px; background-color: #fff; }
                #comInfo ul li.t1 { width: 100px; }
                #comInfo ul li.t2 { width: 900px;}
                #comInfo ul li.t3 { width: 1000px; background-color: #f0f0ee; border: 1px solid #cccccc; margin-top: 20px;text-align:center; }
                #comInfo ul li.t4 { width: 900px; height: 600px; }
                #comInfo ul li.t5 { width: 900px; height: 38px; }
        .textBox { border: 1px solid #cccccc; background-color: white; width: 600px; height: 25px; float: left; }
        .tips { width: 490px; height: 25px; float: left; color: red;font-size:13px }
        .mBtn { width: 119px; height: 34px; background: url(/Areas/AdminMrg/Content/adminImg/M_submit.gif) no-repeat; color: #fff; font-size: 18px; cursor: pointer; }
        .mBtn1 { width:100px;height:26px;background:url(/Areas/AdminMrg/Content/adminImg/M_btn.gif) no-repeat;color:#0076c9;font-size:14px;cursor:pointer;}
    </style>
</head>
<body>
    <div class="Mtop"></div>
    <div class="Mcont">
        <div class="Mleft">@Html.Partial("PartialAdminLeft")</div>
        <div class="Mright">
            <div class="top">
                <div class="btn">
                    <a href="/Account/logOff"><div class="link"></div></a>
                    <a target="_blank" href="@ConstDim.IndexPath"><div class="link"></div></a>
                </div>
                <div class="site">您的位置 / 新闻中心 / 添加新闻</div>
            </div>
            <div class="mid">
                <div id="comInfo">
                    @using (Html.BeginForm("AddNews", "MNews", new { area = "AdminMrg" }, FormMethod.Post, new { enctype = "multipart/form-data" }))
                    {
                        <ul>
                            <li class="t1"><p>新闻名称：</p></li>
                            <li class="t2">@Html.TextBox("NewsName", "", new { @class = "textBox" })</li>
                            <li class="t1"><p>推介首页：</p></li>
                            <li class="t2">@Html.CheckBox("isTop")</li>
                            <li class="t1"><p>发布时间：</p></li>
                            <li class="t2">@Html.TextBox("NewsPostTime", "", new { @class = "textBox laydate-icon", @readonly= "readonly",style = "width:140px" })</li>
                            <li class="t1"><p>新闻类别：</p></li>
                            <li class="t2">
                                @Html.Hidden("NewsCategory")
                                <input type="text" id="tName" class="textBox" readonly = "readonly" disabled="disabled" style = "width:160px"/>
                                <input type="button" value="选择类别" class="table_btn" style="margin-left:10px" onclick="SelectType()"/>
                            </li>
                            <li class="t3"><p>内容：</p></li>
                            <li class="t4">@Html.TextBox("NewsContent", "", new { @class = "textBox", style = "width:1000px;height:600px" })</li>
                            <li class="t5"><input type="submit" value="发布" class="mBtn" onclick="return check()" /></li>
                        </ul>
                    }
                </div>
            </div>
        </div>
    </div>
    <div id="tdMsg" style="display:none">@ViewBag.msg</div>
    <!--日期-->
    <script src="~/CommonResource/laydate/laydate-min.js"></script>
    <link href="~/CommonResource/laydate/skins/danlan/laydate.css" rel="stylesheet" />
    <script src="~/CommonResource/Js/Common.js"></script>
    <!--弹出层-->
    <script src="~/CommonResource/artDialog/jquery.artDialog.source.js?skin=blue"></script>
    <script src="~/CommonResource/artDialog/plugins/iframeTools.source.js"></script>
    <script type="text/javascript">
        var $ID = "#NewsPostTime";
        var postTime = {
            elem: $ID,
            format: 'YYYY-MM-DD hh:mm:ss',
            istime: true,
            istoday: true,
            choose: function (datas) {}
        };
        $(function () {
            //提示语
            var msg = $('#tdMsg').html().trim();
            if (msg != "") {
                alert(msg);
                if (msg == "添加成功") {
                    window.location.href = "/AdminMrg/MNews/Index";
                }
            }
            //展开当前二级菜单
            var $this = $("#Mul li[liName='news'] > a");
            $this.next("ul").slideToggle();
            changeIcon($this);
            //时间
            laydate(postTime);
            $($ID).val(laydate.now(0, 'YYYY-MM-DD hh:mm:ss'));//默认现在当前时间
        });

        function SelectType() {
            var id = Number($("#NewsCategory").val());
            var titleStr = "选择分类";
            var url = "/AdminMrg/MNews/SelectType/"+id;
            var option = {};
            option.title = titleStr;
            option.lock = true;
            option.opacity = 0.25;
            option.backgroundColor = "#777";
            option.width = "350px";
            option.height = "450px";
            option.close = function () {
                //读取iframe页面回传的值
                var typeId = art.dialog.data('ReturnParentId');
                var typeName = art.dialog.data('ReturnParentName');
                $("#NewsCategory").val(typeId);
                $("#tName").val(typeName);
            }
            art.dialog.open(url, option);
        }

        function check() {
            if ($("#NewsName").val() == "") {
                alert("请输入新闻名称");
                return false;
            }
            if ($("#tName").val() == "") {
                alert("请选择类别!");
                return false;
            }
        }
    </script>
</body>
</html>
